package com.yida.gwj.scene.expend.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.utils.poi.ExcelUtil;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.RequiresPermissions;
import com.yida.gwj.scene.expend.domain.GwjSceneExpendBusinessBuild;
import com.yida.gwj.scene.expend.service.IGwjSceneExpendBusinessBuildService;

/**
 * 业务楼栋（线下支出）Controller
 * 
 * @author ruoyi
 * @date 2023-08-14
 */
@RestController
@RequestMapping("/build")
public class GwjSceneExpendBusinessBuildController extends BaseController {
    @Autowired
    private IGwjSceneExpendBusinessBuildService gwjSceneExpendBusinessBuildService;

    /**
     * 查询业务楼栋（线下支出）列表
     */
    @RequiresPermissions("gwj:scene:expend:build:list")
    @GetMapping("/list")
    public TableDataInfo list(GwjSceneExpendBusinessBuild gwjSceneExpendBusinessBuild) {
        startPage();
        List<GwjSceneExpendBusinessBuild> list = gwjSceneExpendBusinessBuildService.selectGwjSceneExpendBusinessBuildList(gwjSceneExpendBusinessBuild);
        return getDataTable(list);
    }

    /**
     * 导出业务楼栋（线下支出）列表
     */
    @RequiresPermissions("gwj:scene:expend:build:export")
    @Log(title = "业务楼栋（线下支出）", businessType = BusinessType.EXPORT, systemName = "gwj")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwjSceneExpendBusinessBuild gwjSceneExpendBusinessBuild) {
        List<GwjSceneExpendBusinessBuild> list = gwjSceneExpendBusinessBuildService.selectGwjSceneExpendBusinessBuildList(gwjSceneExpendBusinessBuild);
        ExcelUtil<GwjSceneExpendBusinessBuild> util = new ExcelUtil<GwjSceneExpendBusinessBuild>(GwjSceneExpendBusinessBuild.class);
        util.exportExcel(response, list, "业务楼栋（线下支出）数据");
    }

    /**
     * 获取业务楼栋（线下支出）详细信息
     */
    @RequiresPermissions("gwj:scene:expend:build:query")
    @GetMapping(value = "/{bizBuildId}")
    public AjaxResult getInfo(@PathVariable("bizBuildId") Long bizBuildId) {
        return AjaxResult.success(gwjSceneExpendBusinessBuildService.selectGwjSceneExpendBusinessBuildByBizBuildId(bizBuildId));
    }

    /**
     * 新增业务楼栋（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:build:add")
    @Log(title = "业务楼栋（线下支出）", businessType = BusinessType.INSERT, systemName = "gwj")
    @PostMapping
    public AjaxResult add(@RequestBody GwjSceneExpendBusinessBuild gwjSceneExpendBusinessBuild) {
        return toAjax(gwjSceneExpendBusinessBuildService.insertGwjSceneExpendBusinessBuild(gwjSceneExpendBusinessBuild));
    }

    /**
     * 修改业务楼栋（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:build:edit")
    @Log(title = "业务楼栋（线下支出）", businessType = BusinessType.UPDATE, systemName = "gwj")
    @PutMapping
    public AjaxResult edit(@RequestBody GwjSceneExpendBusinessBuild gwjSceneExpendBusinessBuild) {
        return toAjax(gwjSceneExpendBusinessBuildService.updateGwjSceneExpendBusinessBuild(gwjSceneExpendBusinessBuild));
    }

    /**
     * 删除业务楼栋（线下支出）
     */
    @RequiresPermissions("gwj:scene:expend:build:remove")
    @Log(title = "业务楼栋（线下支出）", businessType = BusinessType.DELETE, systemName = "gwj")
    @DeleteMapping("/{bizBuildIds}")
    public AjaxResult remove(@PathVariable Long[] bizBuildIds) {
        return toAjax(gwjSceneExpendBusinessBuildService.deleteGwjSceneExpendBusinessBuildByBizBuildIds(bizBuildIds));
    }
}
